<!DOCTYPE html>
<html lang="en">
<head><!--head 用来引入样式文件、JS库-->
    <meta charset="UTF-8">
    <title>watch computed</title>
    <script src="https://cdn.bootcss.com/vue/2.6.7/vue.min.js"></script>
</head>
<body>
<div id="app">
    <p>{{msg}}</p>
    <p>{{msg1}}</p>
</div>
<img src="">

<script>
    var app = new Vue({
        el: '#app',
        data: {
            msg: 'A!',
            another: 'B'
        },
        watch: {
            msg: function (newval, oldval) {
                console.log('new:' + newval + ',old:' + oldval)
            }
        },
        computed: {
            msg1: function () {
                return 'computed ' + this.msg +' '+ this.another;
            }
        }
    })
</script>
</body>
</html>







































